package cn.javase.base.reflect;

import java.lang.reflect.Method;

public class _08_获取成员方法的四种方式 {
    public static void main(String[] args) throws NoSuchMethodException {
        // 方式一
        Class<Student> studentClass = Student.class;
        Method[] methods = studentClass.getMethods();
        for (Method method : methods) {
            System.out.println(method);
        }
        System.out.println("=======================================================================");
        // 方式二
        Method[] declaredMethods = studentClass.getDeclaredMethods();
        for (Method method : declaredMethods) {
            System.out.println(method);
        }
        System.out.println("=======================================================================");
        // 方式三
        Method setName = studentClass.getMethod("setName", String.class);
        System.out.println(setName);
        System.out.println("=======================================================================");
        // 方式四
        Method sayHello = studentClass.getDeclaredMethod("sayHello");
        System.out.println(sayHello);
    }
}
